package br.com.mtg.movethegarbage.graphics;

import javax.microedition.khronos.opengles.GL10;

import br.com.mtg.movethegarbage.framework.Graphics;

public class Camera2D
{
	float x;
	float y;
	float scaleX;
	float scaleY;
	Graphics graphics;

	public Camera2D(Graphics _graphics)
	{
		graphics = _graphics;
		x = 0.0F;
		y = 0.0F;

		scaleX = 1.0F;
		scaleY = 1.0F;
	}

	public void setViewAndMatrices()
	{
		GL10 gl = graphics.getGL();

		gl.glViewport(0, 0, (int) graphics.getWidth(), (int) graphics.getHeight());
		gl.glMatrixMode(GL10.GL_PROJECTION);
		gl.glLoadIdentity();

		gl.glOrthof(x, (graphics.getWidth() + x) * scaleX, y, (graphics.getHeight() + y) * scaleY, 1, -1);

		gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();
	}

	public void setCoordinates(float _x, float _y)
	{
		x = _x;
		y = _y;
	}

	public void setZoom(float zoom)
	{
		scaleX = scaleY = 1.0F / zoom;
	}
}
